package com.tree.backend.controller;

import com.tree.backend.common.Result;
import com.tree.backend.entity.pojo.Company;
import com.tree.backend.service.ICompanyService;
import com.tree.backend.utils.UserContext;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 供电企业信息表 前端控制器
 * </p>
 *
 * @author tree
 * @since 2025-11-09
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/company")
public class CompanyController {
    private final ICompanyService companyService;

    // 订阅套餐功能
    @PutMapping
    public Result<String> subscribe(@RequestBody Company company) {
        company.setId(UserContext.getCompanyId());
        return Result.success(companyService.updateById(company) ? "订阅成功" : "订阅失败");
    }

    @GetMapping
    public Result<Company> getInfo() {
        return Result.success(companyService.getById(UserContext.getCompanyId()));
    }


}
